package com.miyake.client.datamanage;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;
import com.miyake.client.DataService;
import com.miyake.client.DataServiceAsync;
import com.miyake.client.tools.FormatLabel;

public class ShowFixedText {
	private DataServiceAsync service = DataService.Util.getInstance();
	
	public ShowFixedText(NodeProperty node, Panel panel) {
		final HTML label = new HTML();
		panel.add(label);
		service.getText(node.getKey(), new AsyncCallback<Text>() {
			@Override
			public void onFailure(Throwable caught) {
			}

			@Override
			public void onSuccess(final Text result) {
				String html = new FormatLabel() {
					@Override
					public boolean isBold() {
						return result.getBold();
					}

					@Override
					public int getHorizontalAlign() {
						return result.getAlign();
					}
					
				}.getHTML(result.getText());
				label.setHTML(html);
			}
		});
	}
}
